package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Location;
import com.google.gwt.event.shared.HasHandlers;

public class LocationCreatedEvent extends
		GwtEvent<LocationCreatedEvent.LocationCreatedHandler> {

	public static Type<LocationCreatedHandler> TYPE = new Type<LocationCreatedHandler>();
	private Location location;

	public interface LocationCreatedHandler extends EventHandler {
		void onLocationCreated(LocationCreatedEvent event);
	}

	public LocationCreatedEvent(Location location) {
		this.location = location;
	}

	public Location getLocation() {
		return location;
	}

	@Override
	protected void dispatch(LocationCreatedHandler handler) {
		handler.onLocationCreated(this);
	}

	@Override
	public Type<LocationCreatedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<LocationCreatedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Location location) {
		source.fireEvent(new LocationCreatedEvent(location));
	}
}
